﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace LanDBom.Models.Admin
{
    public class Admin__Append
    {
        LDbaseEntities LD = new LDbaseEntities();
        public int AddEmployee(Dengli dl)
        {
            
            if (dl.DE_ID==null)
            {
                LD.Dengli.Add(dl);
            }
            else
            {
                var shu= LD.Dengli.FirstOrDefault(s => s.DE_ID == dl.DE_ID);
                shu.DE_nae = dl.DE_nae;
                shu.DE_ID = dl.DE_ID;
                shu.DE_bumeng = dl.DE_bumeng;
                shu.DE_dizhi = dl.DE_dizhi;
                shu.DE_email = dl.DE_email;
                shu.DE_Pass = dl.DE_Pass;
                shu.DE_phone = dl.DE_phone;
                shu.DE_shenfen = dl.DE_shenfen;
                shu.DE_quan = dl.DE_quan;
                LD.Entry(shu).State = EntityState.Modified; 
            }
            return LD.SaveChanges();
        }
        //无物料名是根据料号搜索物料
        public Formation Liao(string liaohao)
        {
            var dfgh = LD.Formation.FirstOrDefault(s => s.FM_bai == liaohao);
            return dfgh;
        }
        //无料好是根据物料名称搜索物料
        public Formation Wulao(string liaohao)
        {
            var dfgh = LD.Formation.FirstOrDefault(s => s.FM_name == liaohao);
            return dfgh;
        }
        
    }
}